package com.bci.internal.engine.bcibpmengine.controller;


import com.bci.internal.engine.bcibpmengine.service.ActivitiTaskService;
import com.bci.internal.engine.bcibpmengine.support.RestResult;
import com.bci.internal.engine.bcibpmengine.vo.CompleteTaskVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 任务处理类
 *
 * @author jzwu
 * @since 2021/4/5 0005
 */
@Api(tags = "通用流程引擎任务接口")
@RestController
@RequestMapping("/task")
public class ActivitiTaskController {
    @Resource
    private ActivitiTaskService taskService;

    @ApiOperation("根据用户名获取待办任务")
    @GetMapping(value = "/listTasks")
    public RestResult<?> listTasks(@RequestParam("assignee") String assignee,
                                   @RequestParam("page") int page,
                                   @RequestParam("pageSize") int pageSize) {
        return RestResult.builder().data(taskService.listTasks(assignee, page, pageSize)).build();
    }

    @ApiOperation("根据用户名完成待办任务")
    @PostMapping(value = "/completeTask")
    public RestResult<?> completeTask(@RequestBody CompleteTaskVo completeTaskVo) {
        return RestResult.builder().data(taskService.completeTask(completeTaskVo)).build();
    }
}